#ifndef TABLE_ITEM_H
#define TABLE_ITEM_H
#include <QString>
#include <QMetaType>
#include <QList>
#include <QDebug>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <memory>
#include "constant.h"

struct UserInfo
{
    int user_id;
    QString name;
    static void json2data(const QJsonObject &data,UserInfo &user_data);
};

Q_DECLARE_METATYPE(UserInfo)
struct TableItem
{
    int id;
    QString name;
    int status;
    QList<UserInfo> users;
    static void json2data(const QJsonObject &data,TableItem &table_item_data);
};

Q_DECLARE_METATYPE(TableItem)
struct TableAction
{
    int action;
    QVector<dymy::CARD_t> cards;
    int id;
    int index;
    static void json2data(const QJsonObject &data,TableAction &action_data);
};

Q_DECLARE_METATYPE(TableAction)
struct TableUser
{
    QVector<dymy::CARD_t> cards;
    QString name;
    bool prepared;
    int role;
    int user_id;
    int status;
    QVector<dymy::CARD_t> played_cards;
    static void json2data(const QJsonObject &data,TableUser &table_user_data);
};

Q_DECLARE_METATYPE(TableUser)
struct TabaleData
{
    TableAction action_params;
    int action_result;
    UserInfo action_user;
    QVector<dymy::CARD_t> cards3;
    QVector<dymy::CARD_t> current_play_max_cards;
    int current_play_max_cards_type;
    int id;
    int landlord_index;
    int play_cards_index;
    int prev_play_max_card_index;
    int step;
    QVector<TableUser> users;
    int winner_index;
    static void json2data(const QJsonObject &data,TabaleData &table_data);
};

Q_DECLARE_METATYPE(TabaleData)

struct ChatContentData
{
    QString message;
    int time;
    static void json2data(const QJsonObject &data,ChatContentData &a_chat_content_data);
};

Q_DECLARE_METATYPE(ChatContentData)
struct ChatData
{
    int user_id;
    QString name;
    ChatContentData content;
    static void json2data(const QJsonObject &data,ChatData &cdata);
};

struct ChatTableData:public ChatData
{
    int table_id;
    static void json2data(const QJsonObject &data,ChatTableData &cdata);
};
Q_DECLARE_METATYPE(ChatData)

struct PersonNotifyhData
{
    TableAction action_params;
    int action_result;
    UserInfo action_user;
    static void json2data(const QJsonObject &data,PersonNotifyhData &cdata);
};
Q_DECLARE_METATYPE(PersonNotifyhData)
#endif // TABLE_ITEM_H
